
class Grenade:
    def __init__(self,atk=0):
        self.atk = atk

    def explode(self,target):
        print("爆炸")
        if isinstance(target,AttackTarget):
            # 编码时：调用父
            # 运行时：执行子
            target.damage()


class AttackTarget:
    def __init__(self,hp=0):
        self.hp = hp

    def damage(self,value):
        self.hp -= value

class Player(AttackTarget):
    def damage(self,value):
        print("碎屏")
        super().damage(value)

class Enemy(AttackTarget):
    def damage(self,value):
        print("爆头了")
        super().damage(value)

grenade = Grenade()
player = Player()
enemy = Enemy()
grenade.explode(player)
grenade.explode(enemy)